package cn.edu.fudan.dsm.MultiIndexes.Utils;

import cn.edu.fudan.dsm.MultiIndexes.operator.TimeSeriesOperator;
import cn.edu.fudan.dsm.MultiIndexes.operator.file.TimeSeriesFileOperator;
import org.omg.CORBA.DataOutputStream;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

import java.io.IOException;
import java.util.List;

public class GenerateQuery {
    public static void main(String[] args){
        long fileLength = 1000000000;
        int seriesLength = 10000;

        File queryFile = new File("files/data/query_l_10000");
        try (FileOutputStream fos = new FileOutputStream(queryFile)){
            java.io.DataOutputStream dos = new java.io.DataOutputStream(fos);
            TimeSeriesOperator timeSeriesOperator = new TimeSeriesFileOperator("files/data/1000000000", fileLength, seriesLength, false);
            for(long i = 0; i < fileLength / seriesLength; i++) {
                System.out.println(i);
                if(i < 99900)continue;
                List<Double> ts = timeSeriesOperator.readTimeSeries(i * seriesLength, seriesLength);
                for(int j = 0; j < ts.size(); j++){
                    dos.writeFloat((float)ts.get(j).doubleValue());
                }
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
